package cn.dai.dao;

import cn.dai.pojo.User;
import cn.dai.pojo.UserRoleMap;
import cn.dai.util.JdbcUtils;

import java.util.List;

/**
 * @author ArkD42
 * @file RBAC
 * @create 2020 - 06 - 13 - 20:36
 */
public class UserRoleMapDaoImpl implements UserRoleMapDao {

    @Override
    public UserRoleMap queryUrMapByUidAndStatus1(Integer u_id){

        final String sql = "SELECT * FROM `ur_map` WHERE user_id  = ? AND ur_status = 1";

        return JdbcUtils.queryOne(
                JdbcUtils.getConnection(),
                UserRoleMap.class,
                sql,
                new Object[]{u_id}
        );
    }

    @Override
    public List<UserRoleMap> queryUrMapByUid(Integer u_id) {

        final String sql = "SELECT * FROM `ur_map` WHERE user_id  = ?";

        return JdbcUtils.queryToList(
                JdbcUtils.getConnection(),
                UserRoleMap.class,
                sql,
                new Object[]{u_id}
        );
    }


}
